/**
 * 功能描述
 */
define(function (require, exports, module) {
    //引入视图基类
    var ELView = require("elview");

    //assets
    var template = require("./assets/tpl/mealrecord_main.tpl");
    require("./assets/css/mealrecord_main.css");

    //business

    //component
    var mealrecordSubnavComp = require("./component/mealrecordSubnavComp");
    var mealrecordGridComp = require("./component/mealrecordGridComp");
    var mealrecordDetailGridComp = require("./component/mealrecordDetailGridComp");
    
    //constant

    //handler

    //store

    var App = ELView.extend({
        attrs: {
            template: template
        },
        initComponent: function (params, widget) {
        	mealrecordSubnavComp.initComponent(params, widget);
        	mealrecordGridComp.initComponent(params, widget);
        	mealrecordDetailGridComp.initComponent(params, widget);
        },
        afterInitComponent: function (params, widget) {
        	var subnav=widget.get("subnav");
        	widget.get("grid").refresh(null,function(datas){
        		var k = 0;
        		for(var i in datas){
        			k+=(datas[i].totalMoney == null ? 0 : Number(datas[i].totalMoney));
        		}
        		var j = parseFloat(k).toFixed(2);
        		widget.get("grid").setTitle("用餐人数:" + datas.length + "人，共消费:"+ j);
        	})
        }
    });

    module.exports = App;
});
